home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Source / Asm / Blitter / PixelTrail1.s < prev    next >
Text File  |  1997-12-16  |  5KB  |  203 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Pixel Trail #1
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo demonstrates the usefulness of LISTs, by drawing a trail of
  7. ;pixels attached to the mouse.  In the case of pixels there are special
  8. ;routines for drawing with lists, so the drawing is very fast.
  9. ;
  10. ;Press LMB to exit.
  11.  
  12.     INCDIR    "GMSDev:Includes/"
  13.     INCLUDE    "dpkernel/dpkernel.i"
  14.  
  15.     SECTION    "Demo",CODE
  16.  
  17. ;===========================================================================;
  18. ;                             INITIALISE DEMO
  19. ;===========================================================================;
  20.  
  21.     STARTDPK
  22.  
  23. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  24.     move.l    DPKBase(pc),a6
  25.     lea    ScreenTags(pc),a0
  26.     sub.l    a1,a1
  27.     CALL    Init
  28.     tst.l    d0
  29.     beq.s    .Exit
  30.  
  31.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  32.     CALL    Get
  33.     move.l    d0,JoyData
  34.     beq.s    .Exit
  35.     move.l    d0,a0    ;Initialise the joydata structure.
  36.     sub.l    a1,a1
  37.     CALL    Init
  38.     tst.l    d0
  39.     beq.s    .Exit
  40.  
  41.     move.l    Screen(pc),a0
  42.     CALL    Display
  43.  
  44.     bsr.s    Main
  45.  
  46. .Exit    move.l    DPKBase(pc),a6
  47.     move.l    JoyData(pc),a0
  48.     CALL    Free
  49.     move.l    Screen(pc),a0
  50.     CALL    Free
  51.     MOVEM.L    (SP)+,A0-A6/D1-D7
  52.     moveq    #ERR_OK,d0
  53.     rts
  54.  
  55. ;===========================================================================;
  56. ;                                MAIN LOOP
  57. ;===========================================================================;
  58.  
  59. Main:    lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  60. .loop    move.l    BLTBase(pc),a6
  61.     move.l    Screen(pc),a1
  62.     move.l    GS_Bitmap(a1),a0
  63.     move.l    GS_MemPtr2(a1),BMP_Data(a0)
  64.     CALL    bltClearBitmap
  65.  
  66.     move.l    Screen(pc),a0
  67.     move.l    a2,a3    ;Drop the pixels here.
  68.     moveq    #31-1,d7
  69. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  70.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  71.     bge.s    .colok
  72.     clr.l    4(a3)
  73. .colok    addq.w    #8,a3
  74.     dbra    d7,.drop
  75.  
  76.     move.l    DPKBase(pc),a6
  77.     move.l    JoyData(pc),a0
  78.     CALL    Query
  79.  
  80.     move.l    JoyData(pc),a0
  81.     move.l    JD_Buttons(a0),d0
  82.     btst    #JB_LMB,d0
  83.     bne    .done
  84.  
  85.     lea    MouseX(pc),a5
  86.     move.w    JD_YChange(a0),d0
  87.     add.w    d0,2(a5)    ;d1 = (MouseY)+ChangeY
  88.  
  89.     move.w    JD_XChange(a0),d0
  90.     add.w    (a5),d0
  91.  
  92.     move.l    Screen(pc),a0
  93. .ChkRX    cmp.w    GS_Width(a0),d0
  94.     blt.s    .ChkLX
  95.     clr.w    (a5)
  96.     bra.s    .Calculate
  97. .ChkLX    tst.w    d0
  98.     bgt.s    .okX
  99.     move.w    GS_Width(a0),(a5)
  100.     bra.s    .Calculate
  101. .okX    move.w    d0,(a5)
  102.  
  103. .Calculate
  104.     move.l    (a5),-(sp)
  105.     moveq    #2,d1
  106.     CALL    FastRandom
  107.     subq.w    #1,d0
  108.     add.w    d0,(a5)
  109.  
  110.     moveq    #2,d1
  111.     CALL    FastRandom
  112.     subq.w    #1,d0
  113.     add.w    d0,2(a5)
  114.  
  115.     move.l    a2,a3
  116.     moveq    #31-1,d7
  117. .tloop    move.l    8(a3),(a3)
  118.     move.l    12(a3),4(a3)
  119.     addq.w    #8,a3
  120.     dbra    d7,.tloop
  121.  
  122.     move.l    BLTBase(pc),a6
  123.     move.l    Screen(pc),a0
  124.     move.l    GS_Bitmap(a0),a0
  125.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  126.     CALL    bltDrawPixelList    ;>> = Draw pixels with clipping.
  127.  
  128.     move.l    (sp)+,(a5)
  129.  
  130.     move.l    SCRBase(pc),a6
  131.     CALL    scrWaitAVBL
  132.     move.l    Screen(pc),a0
  133.     CALL    scrSwapBuffers
  134.     bra    .loop
  135.  
  136. .done    rts
  137.  
  138. ;===========================================================================;
  139. ;                                  DATA
  140. ;===========================================================================;
  141.  
  142. JoyData:    dc.l  0
  143.  
  144. ScreenTags:    dc.l  TAGS_SCREEN
  145. Screen:        dc.l  0
  146.         dc.l  GSA_Palette,.palette
  147.         dc.l  GSA_Attrib,DBLBUFFER
  148.         dc.l    GSA_BitmapTags,0
  149.         dc.l    BMA_AmtColours,32
  150.         dc.l    TAGEND,0
  151.         dc.l  TAGEND
  152.  
  153. .palette    dc.l  PALETTE,32
  154.         dc.l  $000000,$101010,$171717,$202020,$272727,$303030,$373737,$404040
  155.         dc.l  $474747,$505050,$575757,$606060,$676767,$707070,$777777,$808080
  156.         dc.l  $878787,$909090,$979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  157.         dc.l  $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0,$f7f7f7,$ffffff
  158.  
  159. PixelList:    dc.w   32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  160.         dc.l   MList    ;Pointer to pixel list array.
  161. MList:        PIXEL  160,128,00    ;First pixel to draw (at back)
  162.         PIXEL  160,128,00    ;X/Y/Colour
  163.         PIXEL  160,128,00    ;..
  164.         PIXEL  160,128,00    ;..
  165.         PIXEL  160,128,00    ;..
  166.         PIXEL  160,128,00    ;..
  167.         PIXEL  160,128,00    ;..
  168.         PIXEL  160,128,00    ;..
  169.         PIXEL  160,128,00    ;..
  170.         PIXEL  160,128,00    ;..
  171.         PIXEL  160,128,00    ;..
  172.         PIXEL  160,128,00    ;..
  173.         PIXEL  160,128,00    ;..
  174.         PIXEL  160,128,00    ;..
  175.         PIXEL  160,128,00    ;..
  176.         PIXEL  160,128,00    ;..
  177.         PIXEL  160,128,00    ;..
  178.         PIXEL  160,128,00    ;..
  179.         PIXEL  160,128,00    ;..
  180.         PIXEL  160,128,00    ;..
  181.         PIXEL  160,128,00    ;..
  182.         PIXEL  160,128,00    ;..
  183.         PIXEL  160,128,00    ;..
  184.         PIXEL  160,128,00    ;..
  185.         PIXEL  160,128,00    ;..
  186.         PIXEL  160,128,00    ;..
  187.         PIXEL  160,128,00    ;..
  188.         PIXEL  160,128,00    ;..
  189.         PIXEL  160,128,00    ;..
  190.         PIXEL  160,128,00    ;..
  191.         PIXEL  160,128,00    ;..
  192. MouseX:        PIXEL  160,128,31    ;Last pixel to draw (in front)
  193.  
  194. ;===========================================================================;
  195.  
  196. ProgName:    dc.b  "Pixel Trail I",0
  197. ProgAuthor:    dc.b  "Paul Manias",0
  198. ProgDate:    dc.b  "15 December 1997",0
  199. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  200. ProgShort:    dc.b  "Pixel trail demonstration.",0
  201.         even
  202.  
  203.